package cn.gok.mmall.controller.backend;

import cn.gok.mmall.common.ServerResponse;
import cn.gok.mmall.service.ICategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: chenfan
 * @Description:
 */
@RestController
@RequestMapping("/manage/category")
public class CategoryManagementController {

    @Autowired
    private ICategoryService categoryService;


    @GetMapping("/get_category.do")
    public ServerResponse getCategory(@RequestParam(value = "categoryId",defaultValue = "0") Integer categoryId){
        ServerResponse serverResponse = categoryService.getCategoriesByParentId(categoryId);
        return serverResponse;
    }

    @GetMapping("/get_deep_category.do")
    public ServerResponse getDeepCategory(@RequestParam(value = "categoryId",defaultValue = "0") Integer categoryId){
        ServerResponse serverResponse = categoryService.getAllCategoriesByParentId(categoryId);
        return serverResponse;
    }

}
